package entity

import (
	"GoMaestro/internal/entity/app"
	"time"
)

// AppConfig 结构体对应数据库表 `app_configs`
type AppConfig struct {
	ConfigID  int        `gorm:"primaryKey;autoIncrement" json:"config_id"`
	AppID     int        `gorm:"index;not null" json:"app_id"` // 添加索引
	Env       string     `gorm:"size:100;not null" json:"env"`
	CreatedAt time.Time  `gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time  `gorm:"type:timestamp;not null;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"updated_at"`
	DeletedAt *time.Time `gorm:"type:timestamp;default:null" json:"deleted_at"`

	// 外键关联
	App app.App `gorm:"foreignKey:AppID;references:AppID" json:"app"`
}

// TableName 指定数据库表名（可选）
func (AppConfig) TableName() string {
	return "app_configs"
}
